/**
 * 实现instanceof关键字的功能
 * @param {*} left 
 * @param {*} right 
 * @returns {boolean}
 */
function myInstanceof(left, right) {
    if (typeof right !== 'function' || right == null) {
        throw new TypeError('Right-hand side of instanceof is not callable');
    }
    // 获取 right.prototype
    const prototype = right.prototype;
    // 获取left的隐式原型
    let proto = Object.getPrototypeOf(left);
    while (proto !== null) {
        if (proto === prototype) {
            return true;
        }
        proto = Object.getPrototypeOf(proto);
    }
    return false;
}
